*This file creates Tables 1, 2 and 3

use "$data/hhindiv04_labor.dta", clear

*From hivlabor_5.do
*Merge in BED and vload data here
sort barcode
cap drop _merge
merge (barcode) using "$stata/bed_stata2.dta"
*ignore error message: those without a unique barcode just have a missing barcode.
assert _merge==1 | _merge==3
ren _merge _mergebed
sort barcode
merge (barcode) using "$stata/viralload_stata2.dta"
*5 obs only in the vload data have no viralload, so drop them
ren _merge _mergevload
drop if _mergevload==2


*TABLE 1
count
count if agegroup>1
count if finresfh==1 & agegroup>1
count if result==1 & agegroup>1
*Use HSRC-recommended BED cutoff of 0.75 for 6-month incidence
count if result==1 & agegroup>1 & bedres>.75 & bedres~=.


*TABLE 2
tab race if agegroup>1 & finresfh==1
tab race result if agegroup>1 & finresfh==1 [aw=ibreal12], row nofreq

*TABLE 3
bysort female: tab newempstat positive if group==1 & african==1 [aw=ibreal12], col nofreq mi

